﻿package away3d.primitives.withRB {
	
	import away3d.primitives.Plane;
	import jiglib.physics.RigidBody;
	import jiglib.geometry.JPlane;
	import jiglib.physics.PhysicsSystem;
	import away3d.containers.Scene3D;
	
	public class PlaneWithRB extends Plane implements IPrimitiveWithRB {

		public var rb: RigidBody; 
		
		public function PlaneWithRB(objPrimitive:Object = null, objRB:Object = null, scene: Scene3D = null) {
			super(objPrimitive);
			if (scene != null) {
				scene.addChild(this);
			}
			this.rb = new JPlane(this);
			PhysicsSystem.getInstance().AddBody(this.rb);
			this.rb.setProps(objRB);
		}
		
		public function updateRigidBodyPositionFromModel(): void {
			this.rb.MoveTo(new JNumber3D(this.x, this.y, this.z), this.rb.CurrentState.Orientation);
		}
		
		public function updateRigidBodyDimensionAndPositionFromModel(): void {
			//this.updateRigidBodyDimensionFromModel();
			this.updateRigidBodyPositionFromModel()
		}
		
	}
	
}